var root = ui("$");
var nf = sm("do_Notification");
var pubUrl = require("url/pub");
var helperOpen = require("helper/open");
var bizzType = require("helper/bizzType");
var imHelper = require("helper/im");

//设置数据绑定的映射关系
root.setMapping({
	"linearLayoutRoot.tag" : "id",
    "labelContent.text" : "content",
    "labelTime.text" : "dayMinutesNewAt",
    "imgLogo.tag" : "creatorId",
    "imgLogo.source" : "fullCreatorImg",
    "lableUserName.text" : "creatorName",
    "lableBizz.tag" : "bizzId",
    "lableBizz.text" : "bizzType",
    "lableBizzTitle.text" : "bizzTitle",
    "ImgBizzImg.tag" : "imgItems",
    "ImgBizzImg.visible" : "hasImg"
});

root.on("dataRefreshed", function(){
	var imgItems = JSON.parse(ui("ImgBizzImg").tag);
	if(imgItems!=null && imgItems.length>0){
		ui("ImgBizzImg").source = imgItems[0].source;
	}
})

ui("linearLayout_1").on("touch",function(){
	var bizzId = ui("lableBizz").tag;
	var type= ui("lableBizz").text;
	if(type == bizzType.Level2.CIRCLE_TOPIC){
		helperOpen.open("source://view/circle/topic/detail/topicBorderView.ui",{topicId:bizzId});
	}else if(type == bizzType.Level2.COMMUNITY_MESSAGE){
		helperOpen.open("source://view/community/message/detail/msgBorderView.ui",{id:bizzId});
	}
	
	var commentId = ui("linearLayoutRoot").tag;
	if(commentId){
		imHelper.removeReadedCommentId({commentId:commentId});
	}	
})

//点击头象到他的家
ui("alayoutLogo").on("touch",function(){
	var userId = ui("imgLogo").tag;
	if(userId){
		helperOpen.openPersonal(userId);
	}
})